package com.softeem.files;

import java.io.File;
import java.io.FileFilter;

public class File_02 {
    public static void main(String[] args) {
        File dir = new File("c:\\file\\test");
        if(dir.isDirectory()){
           File[] fs = dir.listFiles(new MyFilter2());
           for(File f : fs){
               System.out.println(f.getName());
           }
        }else{
            System.out.println("必须是一个目录");
        }
    }
}

class MyFilter2 implements FileFilter{
    @Override
    public boolean accept(File pathname) {
        if(pathname.isDirectory()){//如果当前的参数是一个目录就会返回为true
            return true;
        }
        return false;
    }
}
